﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomColumnDialog.ascx.cs" Inherits="Analysis.Controls.CustomColumnDialog" %>

<script type="text/javascript">
    $(function () {
        $("#columnDialog").dialog({ autoOpen: false, width: 900, height: 650, resizable: false });
        $("#columnDialog").parent().appendTo(jQuery("form:first"));
        $(".ui-dialog-titlebar").hide();
    });

    function showCustomColumn() {
        $('#columnDialog').dialog('open');
    }
</script>

<div id="columnDialog">
    <asp:UpdatePanel runat="server" ID="upColumnDetails" OnLoad="upColumnDetails_Load" UpdateMode="Conditional">
    <ContentTemplate>
                    <div class="fieldset_block col-lg-12 page_area">
                        <fieldset>
                            <legend><h4>Редактор таблицы</h4></legend>
                            <div class="fieldset_cotent form-horizontal">
                            <div class="table-responsive" style="overflow-y:auto;height:450px;">
                                <asp:GridView ID="gridCustomColumn" AutoGenerateColumns="false" runat="server" CssClass="table table-bordered table-hover"
                                    AllowPaging="False" PageSize="20" OnRowDataBound="gridCustomColumn_RowDataBound" OnRowCommand="gridCustomColumn_RowCommand" ShowHeader="true">
                                <Columns>
                                    <asp:TemplateField HeaderText="Отображать">
                                        <ItemTemplate>
                                            <asp:CheckBox runat="server" ID="chbIsVisible" Checked='<%# Bind("IsVisibleBinding") %>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Название поля">
                                        <ItemTemplate>
                                            <asp:HiddenField ID="hidCustomColumnNameOld" Value='<%# Eval("HeaderText") %>' runat="server" />
                                            <asp:TextBox ID="tbCustomColumnName" Text='<%# Eval("HeaderText") %>' runat="server" CssClass="form-control" ValidationGroup="saveCustomColumn" placeholder="Введите название поля"/>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="tbCustomColumnName" runat="server" Text="*" ValidationGroup="saveCustomColumn" CssClass="validation_message" Display="Dynamic" />
                                            <asp:RegularExpressionValidator ID="revCustomColumnName" runat="server" ControlToValidate="tbCustomColumnName" Text="Максимальная длина 256 символов" ValidationGroup="saveCustomColumn" CssClass="validation_message" ValidationExpression="^([\S\s]{1,256})$" Display="Dynamic" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Ширина колонки">
                                        <ItemTemplate>
                                            <asp:TextBox ID="tbColumnWidth" Text='<%# Eval("ColumnWidth") %>' runat="server" CssClass="form-control" ValidationGroup="saveCustomColumn" placeholder="Введите ширину колонки"/>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="tbColumnWidth" Text="Требуется целое число" ValidationGroup="saveCustomColumn" CssClass="validation_message" ValidationExpression="[0-9]{1,10}" Display="Dynamic" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:ImageButton runat="server" ImageUrl="~/images/design/actions_icon/delete_icon.gif" ToolTip="Удалить" Style="vertical-align:middle;"
                                                ID="btnDelete" CommandName="MakeDelete" CommandArgument='<%# Eval("HeaderText") %>' OnClientClick="if (Page_ClientValidate('saveCustomColumn')) {return confirm('Подтвердите удаление поля');} else {return false;}" ValidationGroup="saveCustomColumn" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                </asp:GridView>
                            </div>

                                <div class="button_group">
                                    <asp:Button CssClass="btn btn-info" ID="btnAddCustomColumn" Text="Добавить поле" runat="server" ValidationGroup="saveCustomColumn" onclick="btnAddCustomColumn_Click"/>
                                    <asp:Button CssClass="btn btn-info" ID="btnSaveCustomColumn" Text="Сохранить изменения" runat="server" ValidationGroup="saveCustomColumn" onclick="btnSaveCustomColumn_Click" />
                                    <asp:Button CssClass="btn btn-info" ID="btnCancel" Text="Отмена" runat="server" OnClientClick="$('#columnDialog').dialog('close'); return false;" />                                    
                                </div>
                            </div>
                        </fieldset>
                    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
</div>
